package sourceapi.client.mainpage;

import sourceapi.client.MenuFunction;
import sourceapi.client.MenuItem;
import sourceapi.client.MenuManager;

import com.google.gwt.dom.client.Style.Unit;
import com.google.gwt.user.client.ui.Grid;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.gwt.user.client.ui.Widget;

public class FunctionList {
	
	private static VerticalPanel  ContentCointeiner;
	
	public static void Display( String Name ){
		
		MenuItem ItemList = MenuManager.Get( Name );
		RootPanel Screen = RootPanel.get("MainBody");
		
		if( ItemList == null ){
			return;	
		}
		
		Screen.clear();
		
		ContentCointeiner = new VerticalPanel();
		ContentCointeiner.getElement().getStyle().setPadding(25.0, Unit.PX );
		ContentCointeiner.getElement().getStyle().setPaddingTop(0.0, Unit.PX );
		
		ContentCointeiner.add( Base.GetHeader( Name ) );
		
		ContentCointeiner.add( new HTML("<br>") );
		
		Grid FuncList = new Grid( ItemList.MenuFramework.getWidgetCount(), 2 );
		int Count = 0;
		
		for( Widget Item : ItemList.MenuFramework ){
			
			MenuFunction Func = (MenuFunction) Item;
			
			FuncList.setWidget( Count , 0 , Func.GetClean() );
			FuncList.setHTML( Count , 1, Func.Description );
			
			Count++;
		}
		
		ContentCointeiner.add( FuncList );
		Screen.add( ContentCointeiner );
		
	}
	
}
